package com.itaem.community.core.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import io.swagger.annotations.Api;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.RequestHandler;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * <p>项目名称: community </p>
 * <p>文件名称: SwaggerConfig </p>
 * <p>描述: [类型描述] </p>
 * <p>创建时间: 2020/10/27 </p>
 * <p>作者信息: tomato</p>
 *
 * @author tomato
 * @version v1.0
 */
@Configuration
@EnableKnife4j
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket defaultApi() {
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(getApiInfo())
                .select()
                .apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo getApiInfo() {
        return new ApiInfoBuilder()
                .title("Intelligent Community API Documentation")
                .contact(new Contact("ITAEM", "https://itaem.no.web", "ItaemHaveNoEmail@itaem.com"))
                .description("智能社区项目 API 文档")
                .version("0.1")
                .build();
    }
}
